#include <REGX52.H>
#include "Delay.h"

sbit RCK = P3^5;	//将P34,P35,P36分别重命名为SER，RCK，SRCLK 
sbit SCK = P3^6;
sbit SER = P3^4;

void _74HC595(unsigned char den)
{
	unsigned char i=0;
	for(i=0;i<8;i++)
	{
		SER=den&(0x80>>i);	//0x80为1000 0000，如果den最高位也为1，则输出1000 0000
		SCK=1;			//RCK虽然只有一位，对应非0的数，自身也为1
		SCK=0;
	}
	RCK=1;
	RCK=0;
}

void LED_lattice_screen(unsigned char list,den)
{
	_74HC595(den);	
	P0=~(0x80>>list);
	Delay(1);
	P0=0xFF;
}

unsigned char animation[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x30,0x0C,0x03,0x0C,0x30,0xC0,0x30,
0x0C,0x03,0x0C,0x30,0xC0,0x00,0x00,0x00,
0x70,0x88,0x88,0x88,0x7F,0x00,0x00,0x00,
0x00,0x00,0xFF,0x01,0x01,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

unsigned char i,a,count;
void main()
{
	SCK=0;
	RCK=0;
	while(1)
	{
		for(i=0;i<8;i++)
		{
		LED_lattice_screen(i,animation[i+a]);
		}
		count++;
		if(count>=100)
		{
			Delay(100);
			a++;
			if(a>40)
			{
				a=0;
			}
		}
	}
}